package mn.slide.labmed;

import java.util.Comparator;

import mn.slide.labmed.model.Item;

public class Sortierung<T> implements Comparator<T>
{

	public int compare( T object1 , T object2 )
	{
		String a1 = "" , a2 = "";

		a1 = ((Item) object1).getSorter();
		a2 = ((Item) object2).getSorter();

		if (a1.length() != 0 && a2.length() != 0)
		{
			int n1 = Integer.parseInt(a1);
			int n2 = Integer.parseInt(a2);
			if (n1 >= n2)
				return 1;
			else
				return -1;
		}
		int i = ((Item) object1).getSorter().compareTo(((Item) object2).getSorter());
		if (i != 0)
			return i;
		return ((Item) object1).getTitle().compareTo(((Item) object2).getTitle());

	}

}
